//
//  VectorTest.cpp
//  c++algorithm
//
//  Created by WuDi on 24/03/13.
//  Copyright (c) 2013 WuDi. All rights reserved.
//

#include "VectorTest.h"

int ia[10] = {51,23,45,67,93,20,38,47,16,54};

int main_vector(int argc, const char * argv[])
{
    
    vector<int> vec(ia,ia+10);
    
    vector<int>::iterator it = vec.begin(),end_it = vec.end();
    cout<<"original elements of vector:";
    for(;it!=end_it;++it)
        cout<<*it<<' ';
    
    cout<<"\n";
    
    sort(vec.begin(), vec.end());
    
    cout<<"sorted elements of vector:";
    it = vec.begin();
    end_it = vec.end();
    for(;it!=end_it;++it)
        cout<<*it<<' ';
    
    int search_value;
    cout<<"Please enter search value";
    cin>>search_value;
    vector<int>::iterator found;
    found = find(vec.begin(),vec.end(),search_value);
    if(found!=vec.end())
        cout<<"search_value found!\n\n";
    else
        cout<<"search_value not found!\n\n";
    
    reverse(vec.begin(), vec.end());
    it = vec.begin();
    end_it = vec.end();
    for(;it!=end_it;++it)
        cout<<*it<<' ';
    
    return 0;
}